package com.java1412.adress.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.java1412.adress.domain.ImsFileAdress;
import com.java1412.adress.service.IImsFileAdressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 模型文件地址Controller
 *
 * @author ruoyi
 * @date 2023-12-18
 */
@RestController
@RequestMapping("/adress/adress")
public class ImsFileAdressController extends BaseController
{
    @Autowired
    private IImsFileAdressService imsFileAdressService;

    /**
     * 查询模型文件地址列表
     */
    @PreAuthorize("@ss.hasPermi('adress:adress:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImsFileAdress imsFileAdress)
    {
        startPage();
        List<ImsFileAdress> list = imsFileAdressService.selectImsFileAdressList(imsFileAdress);
        return getDataTable(list);
    }

    /**
     * 导出模型文件地址列表
     */
    @PreAuthorize("@ss.hasPermi('adress:adress:export')")
    @Log(title = "模型文件地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImsFileAdress imsFileAdress)
    {
        List<ImsFileAdress> list = imsFileAdressService.selectImsFileAdressList(imsFileAdress);
        ExcelUtil<ImsFileAdress> util = new ExcelUtil<ImsFileAdress>(ImsFileAdress.class);
        util.exportExcel(response, list, "模型文件地址数据");
    }

    /**
     * 获取模型文件地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('adress:adress:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(imsFileAdressService.selectImsFileAdressById(id));
    }

    /**
     * 新增模型文件地址
     */
    @PreAuthorize("@ss.hasPermi('adress:adress:add')")
    @Log(title = "模型文件地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImsFileAdress imsFileAdress)
    {
        imsFileAdressService.insertImsFileAdress(imsFileAdress);
        return AjaxResult.success(imsFileAdress.getId());
    }

    /**
     * 修改模型文件地址
     */
    @PreAuthorize("@ss.hasPermi('adress:adress:edit')")
    @Log(title = "模型文件地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImsFileAdress imsFileAdress)
    {
        return toAjax(imsFileAdressService.updateImsFileAdress(imsFileAdress));
    }

    /**
     * 删除模型文件地址
     */
    @PreAuthorize("@ss.hasPermi('adress:adress:remove')")
    @Log(title = "模型文件地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imsFileAdressService.deleteImsFileAdressByIds(ids));
    }
}
